<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/11/17
 * Time: 下午4:33
 */

namespace App\Modules\Finance\Models;


use Illuminate\Database\Eloquent\Model;

/**
 * Class CashAccount 银行账户
 * @package App\Modules\Finance\Models
 */
class CashAccount extends Model
{
    protected $table = 'cash_accounts';
    protected $fillable = ['account_name','identity_card','card_number','account_bank','bank','province','status','bank_id', 'is_company', 'phone', 'distribution_channel_id'];

    /**
     * 根据渠道ID获取CashAccount
     * @param $distribution_channel_id
     * @return mixed
     */
    static function getByDistributionChannel($distribution_channel_id)
    {
        return self::where('distribution_channel_id',$distribution_channel_id)->orderBy('id','desc')->first();
    }

    /**
     * 根据渠道ID获取CashAccount
     * @param $distribution_channel_id
     * @return mixed
     */
    static function getInfoByDistributionChannel($distribution_channel_ids)
    {
        return self::whereIn('distribution_channel_id',$distribution_channel_ids)->orderBy('updated_at','desc')->first();
    }

}